<?php

/**
 * Description of CategoryService
 *
 * @author LongLT
 */
class CategoryService {
    
    public function loadTerm($vocabulary_id) {
        return Term::buildDataForList(Term::buildTree($vocabulary_id), null);
    }
    
    public function loadBrand($term_id = null){
        if($term_id === null)
            return CHtml::listData (Brand::model()->findAll(array(
                'select' => 'id, name',
                'order' => 'name',
            )), 'id', 'name');
        else
            return CHtml::listData (Subrand::model()->findAll(array(
                'select' => 'id, name',
                'condition' => 'term_id='.$term_id,
            )), 'id', 'name');
    }
}

?>
